#include<iostream>
#include <string>
#include <queue>
#define Maxsize 50
using namespace std;
typedef struct node{
    char data;
    struct node *lchild;
    struct node *rchild;
}BTNode;
BTNode *trans(string a,int i,int maxsize);
void LevelOrder(BTNode *BT);
int main(){
	int maxsize;
	BTNode *BT;
	string str;
	cin>>str;
	maxsize=str.size();
	BT=trans(str,1,maxsize);
	LevelOrder(BT);
	return 0;
	
}
BTNode *trans(string a,int i,int maxsize){
	BTNode *b;
	if(i>maxsize-1) return NULL;
	if(a[i]=='#') return NULL;
	b=new BTNode;
	b->data=a[i];
	b->lchild=trans(a,2*i,maxsize);
	b->rchild=trans(a,2*i+1,maxsize);
	return b;
}
void LevelOrder(BTNode *BT){
	BTNode *p;
	BTNode *qu[Maxsize];
	int front,rear,flag=0;
	if(BT==NULL){
	 cout<<"NULL";
	 return;
	}
	front=rear=-1;
	rear++;
	qu[rear]=BT;
	while(front!=rear){
		front=(front+1)%Maxsize;
		p=qu[front];
		if(flag==0)cout<<p->data;
		else cout<<" "<<p->data;
		flag=1;
		if(p->lchild!=NULL){
			rear=(rear+1)%Maxsize;
			qu[rear]=p->lchild; 
		}
		if(p->rchild!=NULL){
			rear=(rear+1)%Maxsize;
			qu[rear]=p->rchild;
		}
	}
}


